package com.ruoyi.web.controller.cs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.cs.domain.TBackpackOperate;
import com.ruoyi.cs.domain.TBalanceChange;
import com.ruoyi.cs.service.ITBalanceChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户余额变动Controller
 * 
 * @author ruoyi
 * @date 2022-05-24
 */
@RestController
@Api(tags = {"用户余额变动"})
@RequestMapping("/system/change")
public class TBalanceChangeController extends BasicsController
{
    @Autowired
    private ITBalanceChangeService tBalanceChangeService;

    /**
     * 查询用户余额变动列表
     */
    @ApiOperation("查询用户余额变动列表")
    @PreAuthorize("@ss.hasPermi('system:change:list')")
    @GetMapping("/list")
    public ResponsePageInfo<TBalanceChange> list(TBalanceChange tBalanceChange)
    {
        startPage();
        List<TBalanceChange> list = tBalanceChangeService.selectTBalanceChangeList(tBalanceChange);
        return toResponsePageInfo(list);
    }

    /**
     * 获取用户余额变动详细信息
     */
    @ApiOperation("获取用户余额变动详细信息")
    @PreAuthorize("@ss.hasPermi('system:change:query')")
    @GetMapping(value = "/{id}")
    public Response<TBalanceChange> getInfo(@PathVariable("id") Long id)
    {
        return Response.success(tBalanceChangeService.selectTBalanceChangeById(id));
    }

    /**
     * 新增用户余额变动
     */
    @ApiOperation("新增用户余额变动")
    @PreAuthorize("@ss.hasPermi('system:change:add')")
    @Log(title = "用户余额变动", businessType = BusinessType.INSERT)
    @PostMapping
    public Response<Integer> add(@RequestBody TBalanceChange tBalanceChange)
    {
        return toResponse(tBalanceChangeService.insertTBalanceChange(tBalanceChange));
    }

    /**
     * 修改用户余额变动
     */
    @ApiOperation("修改用户余额变动")
    @PreAuthorize("@ss.hasPermi('system:change:edit')")
    @Log(title = "用户余额变动", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response<Integer> edit(@RequestBody TBalanceChange tBalanceChange)
    {
        return toResponse(tBalanceChangeService.updateTBalanceChange(tBalanceChange));
    }

    /**
     * 删除用户余额变动
     */
    @ApiOperation("删除用户余额变动")
    @PreAuthorize("@ss.hasPermi('system:change:remove')")
    @Log(title = "用户余额变动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Response<Integer> remove(@PathVariable Long[] ids)
    {
        return toResponse(tBalanceChangeService.deleteTBalanceChangeByIds(ids));
    }
}
